#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#define LL long long
using namespace std;
const int maxn = 100100;
int a[maxn],b[maxn],c[maxn];
struct node {
    int v,id;
    bool operator < (const node& a) const {
        return v > a.v || (v==a.v && b[id]>b[a.id]);
    }
}x[maxn],y[maxn];
int vis[maxn],mx[maxn*4];
void build(int l,int r,int rt) {
    if (l==r) {mx[rt]=b[x[l].id]; return ; }
    int mid=(l+r)/2;
    build(l,mid,rt<<1);
    build(mid+1,r,rt<<1|1);
    mx[rt]=max(mx[rt<<1],mx[rt<<1|1]);
}
int ask(int L,int R,int l,int r,int rt) {
    if (L<=l&&r<=R) return mx[rt];
    int mid=(l+r)/2,s=0;
    if (L<=mid) s=max(s,ask(L,R,l,mid,rt<<1));
    if (mid<R) s=max(s,ask(L,R,mid+1,r,rt<<1|1));
    return s;
}
int main(void) {
    freopen("in.txt","r",stdin);
    int n,l; scanf("%d%d",&n,&l);
    for (int i=1;i<=n;i++) {
        scanf("%d%d",&a[i],&b[i]);
        x[i] = (node){a[i]-b[i],i};
        y[i] = (node){a[i],i};
    }
    for (int i=1;i<=n;i++) scanf("%d",&c[i]);
    sort(x+1,x+n+1);
    sort(y+1,y+n+1);
    build(1,n,1);
//    for (int i=1;i<=n;i++) printf("%d(%d) ",x[i].v,x[i].id); puts("");

    int ans=-1;
    LL s=0,cs=0,mxb=0,mnd=1000000000000ll;
    for (int i=1,j=1;i<=n;i++) {
        while (vis[y[j].id]) j++;
        if (s+y[j].v >= l) {ans=i; break;}
        if (i>1) {
            LL bnd = x[i].v+mnd;
//            printf("i = %d, mnd = %I64d, bnd = %I64d\n",i,mnd,bnd);
            int l=1,r=i-1,last=i;
            while (l<=r) {
                int mid=(l+r)/2;
                if (x[mid].v < bnd) {
//                    printf("mid=%d, v=%d\n",mid,x[mid].v);
                    last=min(last,mid),r=mid-1;
                }
                else l=mid+1;
            }
            mxb = (last<=i-1?ask(last,i-1,1,n,1):0);
        }
//        printf("i = %d, mxb = %I64d\n",i,mxb);
        if (s+x[i].v+mxb >= l) {ans = i; break;}
        s += x[i].v;
        vis[x[i].id]=1;
        cs += c[i];
        if (cs >= s) break;
        mnd = min(mnd, s-cs);
    }
    printf("%d\n",ans);
    return 0;
}
